  import request from '@/config/axios'

// 渠道佣金设置 VO
export interface ChannelCommissionSettingVO {
  id: number // 主键ID
  agreementId: number // 合作协议ID
  targetType: number // 目标类型(1=分类级别,2=分类,3=商品)
  targetId: number // 目标ID(分类级别ID/分类ID/商品ID)
  commissionType: number // 佣金类型(1=比例,2=固定金额)
  commissionRate: number // 佣金比例(0-100)，当commission_type=1时有效
  fixedAmount: number // 固定佣金金额，当commission_type=2时有效
  status: number // 状态(0=启用,1=禁用)
  remark: string // 备注
}

// 渠道佣金设置 API
export const ChannelCommissionSettingApi = {
  // 查询渠道佣金设置分页
  getChannelCommissionSettingPage: async (params: any) => {
    return await request.get({ url: `/member/channel-commission-setting/page`, params })
  },


  // 批量创建接口
 createBatchChannelCommissionSetting : async (data: any) => {
  return await request.post({ url: '/member/channel-commission-setting/batch-create', data })
},

  // 查询渠道佣金设置详情
  getChannelCommissionSettingById: async (id: number) => {
    return await request.get({ url: `/member/channel-commission-setting/getById?id=` + id })
  },

  // 新增渠道佣金设置
  createChannelCommissionSetting: async (data: ChannelCommissionSettingVO) => {
    return await request.post({ url: `/member/channel-commission-setting/create`, data })
  },

  // 修改渠道佣金设置
  updateChannelCommissionSetting: async (data: ChannelCommissionSettingVO) => {
    return await request.post({ url: `/member/channel-commission-setting/update`, data })
  },

  // 修改渠道佣金设置状态
  updateChannelCommissionSettingStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.post({ url: `/member/channel-commission-setting/updateStatus`, data: data })
  },

  // 删除渠道佣金设置
  deleteChannelCommissionSettingById: async (id: number) => {
    return await request.get({ url: `/member/channel-commission-setting/delete?id=` + id })
  },

  // 导出渠道佣金设置 Excel
  exportChannelCommissionSetting: async (params) => {
    return await request.download({ url: `/member/channel-commission-setting/export-excel`, params })
  },
}
